/* GUI CONVERTED from ecpsfmrp.p (converter v1.75) Wed Sep 27 08:25:17 2000 */
/* ecpsfmrp.p - SUMMARIZED BOM MATERIALS REPORT                           */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                    */
/* All rights reserved worldwide.  This is an unpublished work.           */
/*V8:ConvertMode=Report                                                   */
/* REVISION: 7.4      LAST MODIFIED: 04/23/95   BY: QZL *H0DB*            */
/* REVISION: 8.6      LAST MODIFIED: 06/12/96   BY: Mariya Kutwal *K00C*  */
/* REVISION: 8.6      LAST MODIFIED: 10/08/97   BY: mzv *K0M7             */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane      */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan     */
/* REVISION: 8.6E     LAST MODIFIED: 02/01/99   BY: *K1Z2* Santhosh Nair  */
/* REVISION: 9.0      LAST MODIFIED: 04/26/99   BY: *J3DF* Jean Miller    */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/14/00 BY: *N0KW* Jacolyn Neder    */
/* REVISION: 9.1      LAST MODIFIED: 08/24/00 BY: *N0MZ* Mudit Mehta      */

/*K00C* qad_wkfl where qad_key1 = ECN-CTRL now replaced with pcc_ctrl */


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

/*K0M7*/ {mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

/*N0MZ*
 * &SCOPED-DEFINE ecpsfmrp_p_1 "(BOM Code)"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE ecpsfmrp_p_2 "    (Parent)"
 * /* MaxLen: Comment: */
 *N0MZ*/

&SCOPED-DEFINE ecpsfmrp_p_3 "Design Group"
/* MaxLen: Comment: */

&SCOPED-DEFINE ecpsfmrp_p_4 "Created By"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */


         define new shared variable ecmnbr like ecm_nbr.
/*K1Z2** BEGIN DELETE **
 *       define new shared variable wkfl_no as integer.
 *       define new shared variable maxwkfl as integer.
 *       define new shared workfile ecd1bom field ecd1bom_par like bom_parent.
 *       define new shared workfile psmstr like ps_mstr.
 *K1Z2** END DELETE */
/*K1Z2*/ define new shared temp-table ecd1bom
/*K1Z2*/                        field ecd1bom_par like bom_parent.
/*K1Z2*/ define new shared temp-table psmstr like ps_mstr.

         define variable ecnbr_fr  like ecm_nbr no-undo.
         define variable ecnbr_to  like ecm_nbr no-undo.
         define variable ecid_fr   like wo_lot no-undo.
         define variable ecid_to   like wo_lot no-undo.
         define variable ecdb_fr   like si_db no-undo.
         define variable ecdb_to   like si_db no-undo.
         define variable ectype_fr like ecm_type no-undo.
         define variable ectype_to like ecm_type no-undo.
         define variable ecdgrp_fr like ecm_assign no-undo.
         define variable ecinit_to like ecm_init no-undo.
         define variable ecinit_fr like ecm_init no-undo.
         define variable ecdgrp_to like ecm_assign no-undo.

         define variable ecmid     like wo_lot no-undo.
         define variable dbase     like si_db no-undo.
         define variable skip1     as character no-undo.
         define variable eff_date  as date no-undo.
         define variable um        like pt_um no-undo.
         define variable qty_oh    like in_qty_oh no-undo.
         define variable orig_qty  like pk_qty no-undo.
         define variable futr_qty  like pk_qty no-undo.
         define variable ecn_qty   like pk_qty no-undo.
         define variable finl_qty  like pk_qty no-undo.
         define variable comp      like ps_mstr.ps_comp no-undo.
         define variable ecn_mod   like mfc_logical no-undo.
         define variable desc1     like pt_desc1 no-undo.
         define variable desc2     like pt_desc2 no-undo.

         define variable wkfl_no_save as integer no-undo.

         
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
            
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
ecnbr_fr        colon 20
            ecnbr_to        colon 45    label {t001.i}
            ecid_fr         colon 20
            ecid_to         colon 45    label {t001.i}
            ecdb_fr         colon 20
            ecdb_to         colon 45    label {t001.i}
            ectype_fr       colon 20
            ectype_to       colon 45    label {t001.i}
            ecdgrp_fr       colon 20    label {&ecpsfmrp_p_3}
            ecdgrp_to       colon 45    label {t001.i}
            ecinit_fr       colon 20    label {&ecpsfmrp_p_4}
            ecinit_to       colon 45    label {t001.i}
         with frame a width 80 side-labels attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



         /* SET EXTERNAL LABELS */
         setFrameLabels(frame a:handle).

         view frame a.
/*K0M7*/ {wbrp01.i}

         main-loop:
         repeat:

            /* WORK FILE LIMIT IS MAINTAINED IN ECN CONTROL FILE. IN CASE   */
            /* ECN CONTROL FILE IS NOT FOUND, 250 WILL BE USED ARBITRARILY. */
            /* FOR A SPECIFC PRODUCT STRUCTURE CHAIN, IF WORK FILE NUMBER   */
            /* REACHES THIS LIMIT, REPORT WILL BE TRUNCATED.                */
            /* NOTE: PROGRESS V7 DOES NOT LIMIT THE NUMBER OF RUN TIME WORK */
            /*       FILE BY USING TEMP-TABLE, THEREFORE THE CURRENT LOGIC  */
            /*       MAY NEED TO BE MODIFIED ONCE PROGRESS V7 HAS BEEN      */
            /*       IMPLEMENTED.                                           */

/*K1Z2* BEGIN DELETE **
 * /*K00C*  find first qad_wkfl no-lock where qad_key1 = "ECN-CTRL" no-error.
 *  *       if available qad_wkfl then maxwkfl = qad_decfld[15].
 *  *       else maxwkfl = 250.
 *  *K00C*/ find first pcc_ctrl no-lock no-error.
 * /*K00C*/ if available pcc_ctrl then maxwkfl = pcc_max_wkfl.
 *          else maxwkfl = 250.
 *K1Z2** END DELETE */

            if ecnbr_to    = hi_char then ecnbr_to    = "".
            if ecid_to     = hi_char then ecid_to     = "".
            if ecdb_to     = hi_char then ecdb_to     = "".
            if ectype_to   = hi_char then ectype_to   = "".
            if ecdgrp_to   = hi_char then ecdgrp_to   = "".
            if ecinit_to   = hi_char then ecinit_to   = "".

/*K0M7*/    if c-application-mode <> 'web':u then
            update
               ecnbr_fr
               ecnbr_to
               ecid_fr
               ecid_to
               ecdb_fr
               ecdb_to
               ectype_fr
               ectype_to
               ecdgrp_fr
               ecdgrp_to
               ecinit_fr
               ecinit_to
            with frame a.

/*K0M7*/    {wbrp06.i &command = update &fields = "  ecnbr_fr ecnbr_to ecid_fr
             ecid_to ecdb_fr ecdb_to ectype_fr ectype_to ecdgrp_fr ecdgrp_to
             ecinit_fr ecinit_to" &frm = "a"}

/*K0M7*/    if (c-application-mode <> 'web':u) or
/*K0M7*/       (c-application-mode = 'web':u and
/*K0M7*/       (c-web-request begins 'data':u))
            then do:

               bcdparm = "".
               {gprun.i ""gpquote.p"" "(input-output bcdparm,12,
                  ecnbr_fr, ecnbr_to, ecid_fr, ecid_to, ecdb_fr, ecdb_to,
                  ectype_fr, ectype_to, ecdgrp_fr, ecdgrp_to, ecinit_fr,
                  ecinit_to,
                  null_char, null_char, null_char, null_char,
                  null_char, null_char, null_char, null_char)"}

               if ecnbr_to    = "" then ecnbr_to    = hi_char.
               if ecid_to     = "" then ecid_to     = hi_char.
               if ecdb_to     = "" then ecdb_to     = hi_char.
               if ectype_to   = "" then ectype_to   = hi_char.
               if ecdgrp_to   = "" then ecdgrp_to   = hi_char.
               if ecinit_to   = "" then ecinit_to   = hi_char.

/*J3DF*/       /* ASSIGNED EXACT FIELD LENGTH TO INPUT VARIABLES        */
/*J3DF*/       /* FOR PROPER RECORD SELECTION AS PER SELECTION CRITERIA */
/*J3DF*/       /* BEGIN ADD SECTION */
               assign
                  ecnbr_fr = string(ecnbr_fr,"x(8)")
                  ecnbr_to = string(ecnbr_to,"x(8)")
                  ecid_fr  = string(ecid_fr,"x(8)")
                  ecid_to  = string(ecid_to,"x(8)")
                  ecdb_fr  = string(ecdb_fr,"x(8)")
                  ecdb_to  = string(ecdb_to,"x(8)").
/*J3DF*/       /* END ADD SECTION */

/*K0M7*/    end.

            {mfselbpr.i "printer" 132}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.

            {mfphead.i}

            for each ecm_mstr where (substring(ecm_nbr,1,8) >= ecnbr_fr
            and substring(ecm_nbr,1,8) <= ecnbr_to)
            and (substring(ecm_nbr,9,8) >= ecid_fr
            and substring(ecm_nbr,9,8) <= ecid_to)
            and (substring(ecm_nbr,17,8) >= ecdb_fr
            and substring(ecm_nbr,17,8) <= ecdb_to)
            and (ecm_type >= ectype_fr and ecm_type <= ectype_to)
            and (ecm_assign >= ecdgrp_fr and ecm_assign <= ecdgrp_to)
            and (ecm_init >= ecinit_fr and ecm_init <= ecinit_to)
            no-lock with frame form01 down side-labels width 132:

               /* SET EXTERNAL LABELS */
               setFrameLabels(frame form01:handle).

               if ecm_nbr = "*000000*" or substring(ecm_nbr,25,1) = "*"
               then next.

               ecmnbr = ecm_nbr.
               ecmid = substring(ecm_nbr,9,8).
               dbase = substring(ecm_nbr,17,8).
/*K1Z2*        wkfl_no = 0.         */

               display
                  {ecform01.i}
               with frame form01 STREAM-IO /*GUI*/ .
               put space(132) skip.

               /* CREATE WORK FILE ecd1bom TO DETERMINE TOP PARENT BEING */
               /* DISPLAYED                                              */
               {gprun.i ""ececrp3a.p""}
/*K1Z2*        wkfl_no_save = wkfl_no.        */

               loop-ecd1bom:
               for each ecd1bom with frame b:
                  /* IF IT IS AN UNINCORPORATED ECN, psmstr WORK FILE IS    */
                  /* CREATED HERE TO SIMULATE LIVE DATABASE                 */
                  if ecm_eff_date = ? then do:
/*K1Z2*              wkfl_no = wkfl_no_save.             */
                     {gprun.i ""ecpsfm01.p"" "(input ecmnbr, input ecd1bom_par)"}
                  end.

                  /* ECN NET CHANGE FORM */
                  {ecform10.i}

                  comp = ecd1bom_par.
                  desc1 = "".
                  desc2 = "".

                  find pt_mstr no-lock where pt_part = comp no-error.
                  if not available pt_mstr then do:
                     find bom_mstr where bom_parent = comp no-lock no-error.
                     if available bom_mstr then do:
                        desc1 = bom_desc.
/*N0MZ*                 desc2 = {&ecpsfmrp_p_1}. */
/*N0MZ*/                desc2 = "(" + getTermLabel("BOM_CODE",20) + ")".
                     end.
                     else next loop-ecd1bom.
                  end.
                  else do:
                     desc1 = pt_desc1.
                     desc2 = pt_desc2.
                  end.

                  /* EXPLODE PART BY MODIFIED PICKLIST LOGIC */
                  {gprun.i ""ecpsfm02.p"" "(input comp)"}

                  if page-size - line-counter < 4 then page.

/*N0MZ*           display string(comp,"x(18)") + {&ecpsfmrp_p_2} @ pk_part */
/*N0MZ*/          display
/*N0MZ*/             string(comp,"x(18)") + "    (" +
/*N0MZ*/                getTermLabel("PARENT",6) + ")" @ pk_part
                     desc1 @ pt_desc1 WITH STREAM-IO /*GUI*/ .
                     down 1.

                  if desc2 > "" then do:
                     display
                        desc2 @ pt_desc1 WITH STREAM-IO /*GUI*/ .
                     down 1.
                  end.

                  ecn_mod = no.

                  /* DISPLAY COMPONENTS BY PRODUCT LINE */
                  for each pk_det where (pk_user = mfguser)
                  break by pk_part with frame b:

                     if pk_lot = "ECN" then ecn_mod = yes.
                     if first-of(pk_part) then
                     assign
                        orig_qty = 0
                        futr_qty = 0
                        ecn_qty = 0.

                     /* BEGINNING QTY: IF A ECN HAS NOT BEEN INCORPORATED OR */
                     /* BEEN INCORPORATED BUT HAS A FUTURE EFFECTIVE DATE,   */
                     /* TODAY'S DATE IS USED TO DTERMINE ORIGINAL QUANTITY   */
                     /* REQUIRED. OTHERWISE (INCORPORATED AND EFFETIVE       */
                     /* TODAY OR EARLIER) ONE DAY EARLIER OF THE EFFECTIVE   */
                     /* IS USED.                                             */
                     if ecm_eff_date = ? or
                        ecm_eff_date > today then eff_date = today.
                     else eff_date = ecm_eff_date - 1.
                     if  (pk_start = ? or pk_start <= eff_date)
                     and (pk_end = ? or eff_date <= pk_end)
                     then orig_qty = orig_qty + pk_qty.

                     /* PLUS PREVIOUS RELEASED ECNs: IF A ECN HAS NOT BEEN   */
                     /* INCORPORATED, ASSOCIATED PRODUCT STRUCTURES THAT     */
                     /* HAVE BEEN MODIFIED BY OTHER ECNS WILL IMPACT FINAL   */
                     /* QUANTITY REQUIRED. ONLY ASSOCIATED STRUCTURES ON     */
                     /* RELEASED ECNS WILL BE CONSIDERED AND TODAY + 751 IS  */
                     /* USED ARBITRARILY TO REPRESENT THEIR EFFECTIVE DATE.  */
                     if ecm_eff_date = ? then eff_date = today + 751.
                     else eff_date = ecm_eff_date - 1.
                     if  (pk_start = ? or pk_start <= eff_date)
                     and (pk_end = ? or eff_date <= pk_end)
                     then futr_qty = futr_qty + pk_qty.

                     /* PLUS THIS ECNs: TODAY + 1501 IS USED ARBITRARILY TO  */
                     /* REPRESENT EFFECTIVE DATE OF AN UNINCORPORATED ECN.   */
                     /* INCORPORATED ECNS ALWAYS HAVE EFFECTIVE DATE.        */
                     if ecm_eff_date = ? then eff_date = today + 1501.
                     else eff_date = ecm_eff_date.
                     if  (pk_start = ? or pk_start <= eff_date)
                     and (pk_end = ? or eff_date <= pk_end)
                     then ecn_qty = ecn_qty + pk_qty.

                     if last-of(pk_part) then do:
                        find pt_mstr no-lock where pt_part = pk_part no-error.
                        finl_qty = ecn_qty.
                        ecn_qty = ecn_qty - futr_qty.
                        futr_qty = futr_qty - orig_qty.

                        if page-size - line-counter < 2 and desc2 > "" then
                           page.

                        if not (orig_qty = 0 and futr_qty = 0 and ecn_qty = 0
                        and finl_qty = 0) then do:
                           display
                              if ecn_mod then "*  " + pk_part
                              else "   " + pk_part @ pk_part
                              pt_desc1 @ pt_mstr.pt_desc1
                              orig_qty
                              futr_qty when (futr_qty <> 0)
                              ecn_qty when (ecn_qty <> 0)
                              finl_qty WITH STREAM-IO /*GUI*/ .

                           down 1.

                           if pt_desc2 > "" then do:
                              display
                                 pt_desc2 @ pt_mstr.pt_desc1 WITH STREAM-IO /*GUI*/ .
                              down 1.
                           end.
                        end.

                        ecn_mod = no.

                     end.

                     
/*GUI*/ {mfguichk.i  &warn=false} /*Replace mfrpchk*/


                  end. /* END OF FOR EACH pk_det */

                  
/*GUI*/ {mfguichk.i  &warn=false} /*Replace mfrpchk*/


               end. /* END OF FOR EACH ecd1bom */

               page.

               
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


            end. /* END OF FOR EACH ecm */

            /* REPORT TRAILER */
            {mfrtrail.i}

         end.  /* END OF main loop */

/*K0M7*/ {wbrp04.i &frame-spec = a}
